# -*- coding: utf-8 -*-
# @Time        :2024/11/5 下午7:11
# @Author      :文刀水寿
# @File        : 05_多线程编程.py
"""
 @Description :演示多线程编程的使用
 import threading

 thread_obj = threading.Thread([group [, targetv [, name [, args [, kwargs]]]]])
 - group:暂时无用， 未来功能的预留函数
 - target:执行的目标任务名
 - args:以元组的方式给执行任务传参
 - kwargs: 以字典方式给执行任务传参
 - name： 线程名，一般不用设置 会自动分配
 # 开始工作
 thread_obj.start()
"""
import time
import threading


def sing(msg):
    while True:
        print(msg)
        time.sleep(1)


def dance(msg):
    while True:
        print(msg)
        time.sleep(1)


if __name__ == '__main__':
    # 创建一个唱歌的线程
    sing_thread = threading.Thread(target=sing, args=("我要唱歌，啦啦啦",))

    # 创建一个跳舞的线程
    dance_thread = threading.Thread(target=dance, kwargs={"msg": "我在跳舞，瓜瓜瓜 "})

    # 让线程去干活
    sing_thread.start()
    dance_thread.start()
